package com.implementsystem.prestacontas.orgaos.dao;

import java.util.List;

import javax.ejb.Stateless;

import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.implementsystem.prestacontas.geral.dao.GenericDao;
import com.implementsystem.prestacontas.orgaos.entity.Orgao;

@Stateless
public class OrgaoDao extends GenericDao<Orgao> {
 
	private static final long serialVersionUID = -1964501451755722853L;
	
	@SuppressWarnings("unchecked")
	public List<Orgao> findAllOrderByDescricao(){
		Criteria criteria = getCriteria(Orgao.class);
		criteria.addOrder(Order.asc("nomeOrgao"));
		
		return criteria.list();
		
	}
	
	public Orgao findByCodigoOrgao(String codigo){
		
		Criteria criteria = getCriteria(Orgao.class);
		criteria.add(Restrictions.eq("codigoOrgao", codigo));
		
		
		return (Orgao)criteria.uniqueResult();
	}

}
